//
//  YTMyHeaderView.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/8/14.
//

#import "YTMyHeaderView.h"
#import "YTMyModel.h"
@interface YTMyHeaderView ()


@property (nonatomic ,strong) UIImageView * userimg;
@property (nonatomic ,strong) UILabel * realName;
@property (nonatomic ,strong) UILabel * userName;
@property (nonatomic ,strong) UILabel * zwLab;


@end


@implementation YTMyHeaderView

+ (instancetype)NewView {
    YTMyHeaderView * view = [YTMyHeaderView new];
    view.clipsToBounds = YES;
    [view newUI];
    return view;
}
- (void)newUI{
    
    MJWeakSelf
    UIImageView * userimg = kimageView(@"task_assigner_defaul_avatar");
    self.userimg = userimg;
    [DTKTool YJBK:kwt(30) andView:userimg andWidth:2 andColor:UIColor.whiteColor];
    [self addSubview:userimg];
    [userimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.width.height.offset(kwt(60));
        make.top.offset(kwt(65));
    }];
    
    UILabel * realName = [DTKTool labelWithText:@"-" andFont:kCFont(23) andTextColor:UIColor.whiteColor];
    self.realName = realName;
    [self addSubview:realName];
    [realName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(90));
        make.top.offset(kwt(70));
    }];
    
    UILabel * userName = [DTKTool labelWithText:@"-" andFont:kFont(18) andTextColor:UIColor.whiteColor];
    self.userName = userName;
    [self addSubview:userName];
    [userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(realName.mas_right).offset(kwt(12));
        make.centerY.equalTo(realName);
    }];
    
    
    UILabel * zwLab = [DTKTool labelWithText:@"管理员" andFont:kFont(14) andTextColor:KcolorHex(@"#CCD5FF")];
    self.zwLab = zwLab;
    [DTKTool YJBK:kwt(13) andView:zwLab andWidth:0.5 andColor:KcolorHex(@"#647EF7")];
    zwLab.textAlignment = NSTextAlignmentCenter;
    [self addSubview:zwLab];
    [zwLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(realName.mas_bottom).offset(kwt(12));
        make.width.offset(kwt(60));
        make.height.offset(kwt(26));
        make.left.offset(kwt(90));
    }];
    
}
- (void)setModel:(YTMyModel *)model{
    _model = model;
    self.realName.text = model.realName;
    self.userName.text = model.userName;
    self.userimg.image = [UIImage imageNamed:(model.userIdentity == 1)?@"task_assigner_defaul_avatar":@"task_assigner_defaul_staff"];
    self.zwLab.text = (model.userIdentity == 1)?@"管理员":@"员工";
}

@end
